﻿#ifdef _WIN32
#include "windows_defines.h"
#endif

#include "../../../../../../unittest/framework/unittest.hh"
#include "pool/service_data_pool.hpp"

#include <iostream>
#include <deque>

FIXTURE_BEGIN(test_service_data_pool)

SETUP([]() {
})

CASE(TestServiceDataPool1) {
    guild_service::detail::service_data_pool<int> pool;
    pool.push(1);
    ASSERT_TRUE(pool.size() == 1);
    ASSERT_TRUE(pool.get(0) == 1);
    pool.set(0, 2);
    ASSERT_TRUE(pool.get(0) == 2);
    
    guild_service::detail::service_data_pool<float, std::list> pool2;
    pool2.push(2.0);
    pool2.push(3.0);
    ASSERT_TRUE(pool2.size() == 2);

    struct GuildBriefData
    {
        int id;
        int level;
    };

    guild_service::detail::service_data_pool<GuildBriefData> pool3(10);
    pool3.set(3, GuildBriefData{4, 5});
    ASSERT_TRUE(pool3.get(3).id == 4);
    ASSERT_TRUE(pool3.get(3).level == 5);
}

CASE(TestServiceDataPool2) {
    guild_service::detail::service_data_pool<int, std::deque> pool;
    pool.push(1);
    ASSERT_TRUE(pool.get(0) == 1);
    pool.set(0, 2);
    ASSERT_TRUE(pool.get(0) == 2);
}

FIXTURE_END(test_service_data_pool)